import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/31 17:10
 */

public class Solution {
    public int minNumberOfFrogs(String croakOfFrogs) {
        char[] croakOf = croakOfFrogs.toCharArray();
        String t = "croak";
        int n = t.length();
        int[] hash = new int[5];

        Map<Character, Integer> index = new HashMap<>();
        for (int i = 0; i < n; i++)
            index.put(t.charAt(i), i);

        for (char ch : croakOf) {
            if (ch == t.charAt(0)) {
                if (hash[n - 1] != 0) hash[n - 1]--;
                hash[0]++;
            } else {
                int i = index.get(ch);
                if (hash[i - 1] == 0) return -1;
                hash[i - 1]--;
                hash[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            if (hash[i] != 0)
                return -1;
        }
        return hash[n - 1];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String s = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.minNumberOfFrogs(s));
        }
    }
}